var RunLayer = cc.Layer.extend({
	arr:null,
	scene:null,
	clock:null,
	ctor:function (parent) {
		this._super();
		this.scene = parent;
		this.scene.addChild(this, 10);
		gg.main = this;
		this.init();
	},
	init:function () {
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callNext.retain();
		this.clock = new Clock(this);
		// 物品库
		this.lib = new Lib(this);
		this.scheduleOnce(function(){
		},1);
	},
	loadTest:function(){
 this.lib.moveLib(TAG_LIB_SALT,400);
	},
	test2:function(){
		var move = cc.moveTo(0.7,cc.p(570,320));
		var rotate = cc.rotateTo(0.8, 90);
		var func = cc.callFunc(function(){
			ss.pour2();
			ss.hide(3, true);
		},this);
		var seq = cc.sequence(move, rotate, func);
		ss.runAction(seq);
	},
	loadBottle:function(pos){
		var bottle=new Bottle(this);
		this.addChild(bottle,11);
		this.loadInLib(bottle, pos,cc.p(gg.width*0.35, gg.height*0.3),1);
	},
	loadCylinder:function(pos){
		var action=gg.flow.flow.action;
		if(action==ACTION_DO1){
			var cylinder=new Cylinder(this,action);
			this.addChild(cylinder,11);
			this.loadInLib(cylinder, pos,cc.p(gg.width*0.25, gg.height*0.35),1);
		}else if(action==ACTION_DO2){
			var cylinder=new Cylinder(this,action);
			this.addChild(cylinder,11);
			this.loadInLib(cylinder, pos,cc.p(gg.width*0.35, gg.height*0.35),1);
		}
		
	},
	loadKettle:function(pos){
		var kettle=new Kettle(this);
		this.addChild(kettle, 10);
		this.loadInLib(kettle, pos,cc.p(gg.width*0.475, gg.height*0.3),1);
	},
	loadBeaker:function(pos){
		var beaker=new Beaker(this);
		this.addChild(beaker,11);
		this.loadInLib(beaker, pos, cc.p(gg.width*0.55, gg.height*0.3),1);
	},
	loadFlask:function(pos){
		var flask=new Flask(this);
		this.addChild(flask,11);
		this.loadInLib(flask, pos,cc.p(gg.width*0.65, gg.height*0.35),1);
	},
	loadRod:function(pos){
		var rod=new Rod(this);
		this.addChild(rod, 10);
		this.loadInLib(rod, pos,cc.p(gg.width*0.55, gg.height*0.42),0)
	},
	loadPipette:function(pos){
		var pipette=new Pipette(this);
		this.addChild(pipette, 11);
		this.loadInLib(pipette, pos,cc.p(gg.width*0.55, gg.height*0.42),0);
	},
	loadPipette1:function(pos){
		var pipette=new Pipette1(this);
		this.addChild(pipette, 10);
		this.loadInLib(pipette, pos,cc.p(gg.width*0.45, gg.height*0.5),0);
	},
	loadK2CrO4:function(pos){
		var k2CrO4=new K2CrO4(this);
		this.addChild(k2CrO4, 11);
		this.loadInLib(k2CrO4, pos, cc.p(gg.width*0.45, gg.height*0.3),1);
	},
	loadIronShelf:function(pos){
		var ironShelf=new IronShelf(this);
		this.addChild(ironShelf, 11);
		this.loadInLib(ironShelf, pos,cc.p(gg.width*0.25,gg.height*0.4),1);
	},
	loadBottle1:function(pos){
		var bottle1=new Bottle1(this);
		this.addChild(bottle1, 11);
		this.loadInLib(bottle1, pos,cc.p(gg.width*0.65, gg.height*0.3),1);
	},
	loadBuret:function(pos){
		var buret=new Buret(this);
		this.addChild(buret, 11);
		this.loadInLib(buret, pos,cc.p(gg.width*0.5,gg.height*0.55),1);
	},
	loadInLib:function(obj, pos, tarPos,state,delay){
		obj.setPosition(pos);
		if(delay == null){
			delay = 1;
		}
		var ber = $.bezier(pos, tarPos, delay);
		if(state==1){
			var seq = cc.sequence(ber, this.callNext);
		}else{
			var seq=cc.sequence(ber);
		}
		obj.runAction(seq);
	},
	kill:function(obj){
		var fade = cc.fadeTo(0.5,0);
		var func = cc.callfunc(function(){
			obj.removeFromParent(true);
		},this);
		var seq = cc.sequence(fade,func);
		obj.runAction(seq)
	}
});